﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="XayDungBoDe.ascx.cs" Inherits="Main.Controls.XayDungBoDe" %>
<!--Còn Việc Giúp Admin Phát Sinh Bộ Đề từ các câu hỏi phù hợp với điều kiện lọc nữa-->
<script type="text/javascript">
    function Check(id1, id2)
    {
        var kq = '';
        if(document.getElementById(id1).value == '')
            kq+='-Chưa nhập tên bộ đề';
        if(document.getElementById(id2).selectedIndex <= 0)
            kq+='\n-Chưa chọn chuyên mục.';
        if(kq!='')
        {
            alert(kq);
            return false;
        }
        return true;
    }
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<div id="Location" class="Location" runat="server"><a href="../Administrator.aspx">Administrator Page</a> >> Quản Lý Bộ Đề </div>
<div id="Notice" class="Notice" runat="server" visible="false"></div>
<div id="Errors" class="Errors" runat="server" visible="false"></div>
<div id="Form">
    <!-- Thêm thông tin bộ đề -->
    <div id="pDanhSachDe" runat="server" style="width:100%">
        <fieldset  style="width:98%">
        <legend>Danh sách bộ đề</legend>
            <!-- Khi đến giai đoạn Code thật thì ở đây chắc phải dùng Template Field thôi, BoundField nhiều khi không đáp ứng được-->
            <asp:GridView  ID="gridDanhSachDe" runat="server" SkinID="GridViewSkin" AutoGenerateColumns="False"  
             OnPageIndexChanging="gridDanhSachDe_PageIndexChanging" OnRowDeleting="gridDanhSachDe_RowDeleting" AllowSorting="true"
              OnRowEditing="gridDanhSachDe_RowEditing" OnRowUpdating="gridDanhSachDe_RowUpdating" OnRowCancelingEdit="gridDanhSachDe_RowCancelingEdit" AllowPaging="True"  ShowFooter="True" OnRowCommand="gridDanhSachDe_RowCommand" OnSorting="gridDanhSachDe_Sorting" OnRowDataBound="gridDanhSachDe_RowDataBound" >
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="chkAll" runat="server" AutoPostBack="True" OnCheckedChanged="chkAll_De_CheckedChanged" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkChon" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ID" SortExpression="MaBoDe">
                        <ItemTemplate>
                            <asp:Label ID="lblMaBoDe" runat="server" Text='<%# Eval("MaDe") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="Label2" runat="server" Text="[Auto]"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="T&#234;n bộ đề" SortExpression="TenBoDe">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtTenBoDe" runat="server" Text='<%# Eval("TenDe") %>' ></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblTenBoDe" runat="server" Text='<%# Eval("TenDe") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtTenBoDe" runat="server"></asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Chuy&#234;n mục" SortExpression="ChuyenMuc">
                        <EditItemTemplate>
                            <asp:DropDownList ID="dropChuyenMuc" runat="server" DataTextField="TenChuyenMuc"  DataValueField="MaChuyenMuc" DataSource='<%# LoadChuyenMuc()%>' SelectedValue='<%#Select((string)Eval("ChuyenMuc.TenChuyenMuc")) %>'  Width="95%">
                            </asp:DropDownList>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblChuyenMuc" runat="server" Text='<%# Eval("ChuyenMuc.TenChuyenMuc") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="dropChuyenMuc" runat="server" DataTextField="TenChuyenMuc" DataValueField="MaChuyenMuc" DataSource='<%# LoadChuyenMuc()%>' Width="95%">
                            </asp:DropDownList>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Số c&#226;u hỏi" SortExpression="SoCau">
                        <ItemTemplate>
                            <asp:Label ID="lblSoCauHoi" runat="server" Text='<%# Eval("SoCauHoi") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="lblSoCauHoiF" runat="server" Text="[Auto]"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Thời gian" SortExpression="ThoiGian">
                        <ItemTemplate>
                            <asp:Label ID="lblThoiGianLamBai" runat="server" Text='<%# Eval("ThoiGianLamBai") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="lblThoiGianF" runat="server" Text="[Auto]"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="M&#244; tả">
                        <EditItemTemplate>
                            <asp:TextBox ID="txtMoTa" runat="server" Width="90%" Text='<%# Eval("MoTa") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblMoTa" runat="server" Text='<%# Eval("MoTa") %>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtMoTa" runat="server" Width="90%"></asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="SL Thực hiện" SortExpression="SoLanThucHien">
                        <ItemTemplate>
                            <asp:Label ID="lblSoLuotThucHien" runat="server" Text='<%# Eval("SoLuotThucHien") %>'>></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Label ID="lblSLF" runat="server" Text="[Auto]"></asp:Label>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Thao t&#225;c">
                        <EditItemTemplate>
                            <asp:LinkButton ID="lnkSave" runat="server" CommandName="Update" ToolTip="Save">
                    <asp:Image ID="imgSave" runat="server" SkinID="Save" />
                </asp:LinkButton><asp:LinkButton ID="lnkCancel" runat="server" CommandName="Cancel"
                                ToolTip="Cancel">
                   <asp:Image ID="imgCancel" runat="server" SkinID="Cancel" />
                </asp:LinkButton>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:LinkButton ID="lnkInsert"  runat="server" CommandName="Insert" ToolTip="Insert">
                   <asp:Image ID="imgInsert" runat="server" SkinID="Insert" />
                </asp:LinkButton>
                        </FooterTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit" ToolTip="Sửa">
                    <asp:Image ID="imgEdit" runat="server" SkinID="Edit" />
                </asp:LinkButton><asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete"
                                OnClientClick="return confirm('Bạn có muốn xóa thật không?');" ToolTip="Xóa">
                     <asp:Image ID="imgDelete" runat="server" SkinID="Delete" />
                </asp:LinkButton>
                            <asp:LinkButton ID="lnkXayDung" runat="server" ToolTip="Xây dựng đề" CommandName='<%# Eval("MaDe") %>' OnClick="lnkXayDung_Click">
                    <asp:Image ID="imgPage" runat="server" SkinID="Page" AlternateText="Xây dựng bộ đề" />
                </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
             <br />
            <label><b>Bulk Action</b>: </label>
            <asp:LinkButton runat="server" CssClass="Button2" id="lnkDeleteAll" Text="Xóa" OnClientClick="return confirm('Bạn có muốn xóa thật không?');" OnClick="lnkDeleteAll_Click"></asp:LinkButton>
             &nbsp;
             <br />
             <br />
        </fieldset>
        
    </div>
    <!--Hạn chế dùng Server Control-->
    <div style="clear:both; "></div>
    <div id="pXayDungDe" runat="server">
        <div style="float:right;">
            <asp:LinkButton ID="lnkBack" runat="server" OnClick="lnkBack_Click" >
                <asp:Image ID="imgBack" runat="server" SkinID="Back" />
            </asp:LinkButton>
        </div>
        <div style="clear:both; "></div>
        <div style="float:left; width:60%">
            <table border="0" cellpadding="0" cellspacing="0">
                 <tr>
                    <td style="height: 22px">Bộ Đề:</td>
                    <td style="height: 22px">
                        <asp:DropDownList id="ddlBoDe" runat="server" style="width:190px;" OnSelectedIndexChanged="ddlBoDe_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
                    </td>
                </tr>
            </table>
        </div>
        <div style="clear:both; "></div>
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
             <tr>                    
                    <td style="height: 19px">
                        Câu Dễ:<asp:Label ID="lblSoCauDe" runat="server" >0</asp:Label>
                    </td>
                        Câu Trung Bình:<asp:Label ID="lblSoCauTrungBinh" runat ="server">0</asp:Label>
                    <td style="height: 19px">
                        Câu Khó:<asp:Label ID="lblSoCauKho" runat="server" >0</asp:Label>
                    </td>
                    <td style="height: 19px">
                        Tổng Cộng:<asp:Label ID="lblTongSoCau" runat="server" >0</asp:Label>
                    </td>
             </tr>
         </table>
        <div style="clear:both;"></div>
        <div style="float:left; width:100%;">
           <fieldset>
                <legend>Điều Kiện Lọc</legend>
                <table>
                    <tr>
                       <td>Chuyên Mục:</td>
                        <td >
                            <asp:DropDownList id="ddlChuyenMuc" runat="server" OnSelectedIndexChanged="ddlChuyenMuc_SelectedIndexChanged" AutoPostBack="True" ></asp:DropDownList>
                        </td>
                        <td>Kỹ Năng: </td>
                        <td style="width: 81px"> 
                            <asp:DropDownList ID="ddlKyNang" runat="server" OnSelectedIndexChanged="ddlKyNang_SelectedIndexChanged" AutoPostBack="True" ></asp:DropDownList></td>   
                        <td>Độ Khó:</td>
                        <td>
                            <asp:DropDownList id="ddlMucDo" runat="server" OnSelectedIndexChanged="ddlMucDo_SelectedIndexChanged" AutoPostBack="True" ></asp:DropDownList>
                        </td>
                        <td>Loại Câu Hỏi:</td>
                        <td>
                            <asp:DropDownList id="ddlLoaiCauHoi" runat="server" OnSelectedIndexChanged="ddlLoaiCauHoi_SelectedIndexChanged" AutoPostBack="True" >
                                
                            </asp:DropDownList>
                        </td>
                     
                    </tr>
                    <tr>
                       <td colspan="4" >
                            <br />
                            <asp:LinkButton ID="lnkThemCauHoiVaoDe" CssClass="Button2" runat="server" OnClick="lnkThemCauHoiVaoDe_Click" Text="Thêm câu hỏi mới"></asp:LinkButton>
                        </td>
                    </tr>
                </table>
                <br />
            </fieldset>
         </div>
         <div style="clear:both;"></div>
           <asp:LinkButton ID="lnkBackCauHoiCon" Visible="false" runat="server" OnClick="lnkBackCauHoiCon_Click" >
                <asp:Image ID="Image1" runat="server" SkinID="Back" />
            </asp:LinkButton>
        <asp:Label ID="lblTieuDe" runat="server" CssClass="Title" Text="Danh Sách Câu Hỏi thuộc Bộ đề"></asp:Label>
         <asp:GridView  SkinID="GridViewSkin" ID="gridDanhSachCauHoi" runat="server" 
          AutoGenerateColumns="False" OnPageIndexChanging="gridDanhSachCauHoi_PageIndexChanging"
           AllowPaging="True" OnRowCommand="gridDanhSachCauHoi_RowCommand" OnLoad="gridDanhSachCauHoi_Load" 
           OnRowEditing="gridDanhSachCauHoi_RowEditing" AllowSorting="true" OnSorting="gridDanhSachCauHoi_Sorting" OnRowDataBound="gridDanhSachCauHoi_RowDataBound">
             <Columns>
                 <asp:TemplateField HeaderText="">
                     <ItemTemplate>
                         <asp:CheckBox ID="chkChon" runat="server" />
                     </ItemTemplate>
                     <HeaderTemplate>
                         <table>
                            <tr>
                                <td>
                                    <asp:CheckBox ID="chkAll" runat="server" AutoPostBack="True" OnCheckedChanged="chkAll_CheckedChanged"
                                    ToolTip="Chọn tất cả" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="lnkCommand" runat="server" CommandName="Xoa" SkinID="DeleteButton" ToolTip="Xóa khỏi danh sách đề"  />
                                </td>
                            </tr>
                         </table>
                     </HeaderTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="M&#227; c&#226;u hỏi" SortExpression="MaCauHoi">
                     <ItemTemplate>
                         <asp:Label ID="lblMaCauHoi" runat="server" Text='<%# Eval("MaCauHoi") %>'>></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="Nội Dung" SortExpression="NoiDung">
                     <ItemTemplate>
                         <asp:Label ID="lblNoiDung" runat="server" Text='<%# GenerateTooltip((int)Eval("MaCauHoi"),(string)Eval("NoiDung"),(object)Eval("DanhSachDapAn")) %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>
                  <asp:TemplateField HeaderText="Mức độ" SortExpression="MucDo">
                    <itemtemplate>
                        <asp:Label id="lblMucDo" runat="server"  Text='<%# Eval ( "MucDo.TenMucDo" ) %>'></asp:Label>
                    </itemtemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Kỹ năng" SortExpression="KyNang">
                    <itemtemplate>
                        <asp:Label id="lblKyNang" runat="server"   Text='<%# Eval ( "KyNang.TenKyNang" ) %>'></asp:Label>               
                    </itemtemplate>
                </asp:TemplateField>
                  <asp:TemplateField HeaderText="Chuy&#234;n mục" SortExpression="ChuyenMuc">
                    <itemtemplate>
                        <asp:Label id="lblChuyenMuc" runat="server"  Text='<%# Eval ( "ChuyenMuc.TenChuyenMuc" ) %>'></asp:Label>    
                    </itemtemplate>
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="Thao t&#225;c">
                     <ItemTemplate>
                         <asp:LinkButton ID="lnkEdit" runat="server" CommandName="Edit" ToolTip="Sửa">
                            <asp:Image ID="imgEdit" runat="server" SkinID="Edit" />
                        </asp:LinkButton>
                     </ItemTemplate>
                 </asp:TemplateField>
             </Columns>
            </asp:GridView>
    </div>
    <div style="clear:both;"></div>
    <asp:HiddenField ID="hidDanhSachTruoc" runat="server"/>
</div>
<div style="clear:both;"></div>
</ContentTemplate>
</asp:UpdatePanel>
   <asp:Image ID="imgDelete" runat="server" SkinID="Delete" Visible="false" />
<asp:Image ID="imgAsc" runat="server" SkinID="ASC" Visible="false" />
<asp:Image ID="imgDesc" runat="server" SkinID="DESC" Visible="false" />
<asp:Image ID="imgInsert" runat="server" SkinID="Insert" Visible="false" />
<asp:Image ID="imgSave" runat="server" SkinID="Save" Visible="false" />

<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
       <ProgressTemplate>
                <div class="overlay" id="divProgress" style="position: absolute">
                    <center>
                        <asp:Image runat="server" ID="AjaxLoading" SkinID="AjaxLoadingIndicator" />
                    </center>
                </div>
        </ProgressTemplate>
</asp:UpdateProgress>
